Imports System.Data.OracleClient

Namespace persistent

    Public Class FRMToolDB

        Public Shared Function SubmitFRMCDRReport(ByVal custCode As String, ByVal contractId As Integer, ByVal snCode As Integer, ByVal startDate As String, ByVal endDate As String, ByVal reqType As Integer, ByVal userName As String) As String()
            Dim command As New OracleCommand("EU_BILL.submitFRMCDRReport")

            command.Parameters.Add("pis_custcode", OracleType.VarChar).Value = custCode
            command.Parameters.Add("pin_co_id", OracleType.Int32).Value = contractId
            command.Parameters.Add("pin_snCode", OracleType.Int32).Value = snCode
            command.Parameters.Add("pis_startDate", OracleType.VarChar, 30).Value = startDate
            command.Parameters.Add("pis_endDate", OracleType.VarChar, 30).Value = endDate
            command.Parameters.Add("pin_req_type", OracleType.Int32).Value = reqType
            command.Parameters.Add("pis_user_name", OracleType.VarChar).Value = userName

            command.Parameters.Add("po_errorCode", OracleType.Int32).Direction = ParameterDirection.Output
            command.Parameters.Add("po_errorDesc", OracleType.VarChar, 2000).Direction = ParameterDirection.Output
            command.Parameters.Add("po_file_dir", OracleType.VarChar, 2000).Direction = ParameterDirection.Output
            command.Parameters.Add("po_file_name", OracleType.VarChar, 2000).Direction = ParameterDirection.Output

            persistent.DataEngine.ExecuteNonQuery(command)

            Dim result(3) As String
            result(0) = CheckDBNull(command.Parameters("po_errorCode").Value)
            result(1) = CheckDBNull(command.Parameters("po_errorDesc").Value)
            result(2) = CheckDBNull(command.Parameters("po_file_dir").Value)
            result(3) = CheckDBNull(command.Parameters("po_file_name").Value)
            Return result

        End Function

        Private Shared Function CheckDBNull(ByVal inputValue As Object) As String
            If IsDBNull(inputValue) Then
                Return String.Empty
            Else
                Return CStr(inputValue)
            End If
        End Function
    End Class

End Namespace